/*
 * utilxml.cpp
 *
 *  Created on: 2008-nov-01
 *      Author: magnus
 */

#include "utilxml.h"

using namespace spacedefender;

bool UtilXml::GetLongAttr(const TiXmlElement* element, const std::string& attrName, long* data)
{
	const char * value= element->Attribute(attrName.c_str());
	bool bOk = false;

	if (value)
	{
		bOk = true;
		*data = strtol(value,NULL,10);
	}
	return bOk;

}

bool UtilXml::GetDoubleAttr(const TiXmlElement* element, const std::string& attrName, double* data)
{
	const char * value= element->Attribute(attrName.c_str());
	bool bOk = false;

	if (value)
	{
		bOk = true;
		*data =  strtod(value,NULL);
	}

	return bOk;
}

bool UtilXml::GetStringAttr(const TiXmlElement* element, const std::string& attrName, std::string* data)
{
	const char * value= element->Attribute(attrName.c_str());
	bool bOk = false;

	if (value)
	{
		bOk = true;
		*data = std::string(value);
	}

	return bOk;
}



